//
// Created by tatyx on 2025/8/26.
//
#include "CyberGear.h"

FDCAN1_TxFrame_TypeDef hfdcan1_TxFrame_Cyber = {
    .hcan   = &hfdcan1,
    .Header.IdType = FDCAN_EXTENDED_ID,
    .Header.TxFrameType = FDCAN_DATA_FRAME,
    .Header.DataLength = FDCAN_DLC_BYTES_8,
    .Header.ErrorStateIndicator = FDCAN_ESI_ACTIVE,
    .Header.BitRateSwitch = FDCAN_BRS_OFF,
    .Header.FDFormat = FDCAN_CLASSIC_CAN,
    .Header.TxEventFifoControl = FDCAN_NO_TX_EVENTS,
    .Header.MessageMarker = 0
  };


void Cyber_FDCAN_TxData_8byteS(FDCAN1_TxFrame_TypeDef *TxFrame, u8 *data, u8 masterID, u8 motorID,u8 mode)
{
    uint32_t id = (mode << 24) | (masterID << 8) | motorID;

    TxFrame->Header.Identifier = id;
    TxFrame->Data[0] = data[0];
    TxFrame->Data[1] = data[1];
    TxFrame->Data[2] = data[2];
    TxFrame->Data[3] = data[3];
    TxFrame->Data[4] = data[4];
    TxFrame->Data[5] = data[5];
    TxFrame->Data[6] = data[6];
    TxFrame->Data[7] = data[7];

    HAL_FDCAN_AddMessageToTxFifoQ(TxFrame->hcan, &TxFrame->Header,TxFrame->Data);
}
extern Cyber_TypeDef Cyber_motor01;

void Cyber_get_ID(Cyber_TypeDef *motor)
{
    u8 data[8] = {0,0,0,0,0,0,0,0};
    Cyber_FDCAN_TxData_8byteS(&hfdcan1_TxFrame_Cyber, data,Cyber_MasterID, motor->motorID,0);

}

void Cyber_data_deal(FDCAN1_RxFrame_TypeDef *RxFrame)//0x   0  00 01   FE
{


}
